package cn.lqz.bucttrain.mapper;

import cn.lqz.bucttrain.annotations.AutoFill;
import cn.lqz.bucttrain.enums.OperationTypeEnum;
import cn.lqz.bucttrain.pojo.dto.TrainPageQueryDTO;
import cn.lqz.bucttrain.pojo.entity.Train;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface TrainMapper {
    /**
     * 分页查询
     * @param trainPageQueryDTO
     * @return
     */
    Page<Train> findBatch(TrainPageQueryDTO trainPageQueryDTO);

    /**
     * 查询
     * @param trainId
     * @return
     */
    @Select("select * from train where train_id=#{trainId}")
    Train findByTrainId(Long trainId);

    /**
     * 删除
     * @param trainId
     */
    @Delete("delete from train where train_id=#{trainId}")
    void deleteByTrainId(Long trainId);

    /**
     * 插入
     * @param train
     */
    @AutoFill(OperationTypeEnum.INSERT)
    void insert(Train train);

    /**
     * 修改
     * @param train
     */
    @AutoFill(OperationTypeEnum.UPDATE)
    void update(Train train);
}
